package com.wfu.mobileplayer;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;

import com.wfu.module_home.ui.HomeActivity;

public class LauncherActivity extends AppCompatActivity {

    private Handler mHandler = new Handler();
    private boolean isEnter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launcher);
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                enterHome();
            }
        }, 2000);
    }

    private void enterHome() {
        if (!isEnter) {
            isEnter = !isEnter;
            startActivity(new Intent(this, HomeActivity.class));
            finish();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mHandler.removeCallbacksAndMessages(null);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        enterHome();
        return super.onTouchEvent(event);
    }
}
